<?php
/**
 * FastApp.
 * 1/5/25
 * @Author 深色的海 (wx:deepsea_0024)
 * @Contact telegram:deepsea159
 */

namespace App\Fastapp\Api\Controller\Crypto;

use App\Fastapp\Api\Controller\ApiController;
use App\Fastapp\Api\Service\Crypto\PayService;
use App\Fastapp\Aspect\ApiAuth;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;


#[Controller('api/crypto'), ApiAuth]
class PayController extends ApiController
{
    #[Inject]
    public PayService $service;

    #[PostMapping('recharge')]
    public function recharge(): ResponseInterface
    {
        return $this->success($this->service->recharge($this->validate([
            'symbol' => 'required',
            'contract' => 'required|in:0,1,2,3',
        ])));
    }

    #[GetMapping('log')]
    public function log(): ResponseInterface
    {
        return $this->success($this->service->log($this->request->input('symbol')));
    }

    #[PostMapping('withdrawal')]
    public function withdrawal(): ResponseInterface
    {
        return $this->success($this->service->withdrawal($this->validate([
            'symbol' => 'required',
            'amount' => 'required',
            'contract' => 'required|in:0,1,2,3,4',
            'to_address' => 'required|string',
        ])));
    }
}